package struts2.sample04.chinchirorin;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;

import static struts2.sample04.chinchirorin.Yaku.*;

@SuppressWarnings("serial")
public class ChichiroUtils {

	private static final Map<String, Yaku> YAKU_MAP = new HashMap<String, Yaku>() {
		{
			put("111", PINZORO);
			put("112", DEME_2);
			put("113", DEME_3);
			put("114", DEME_4);
			put("115", DEME_5);
			put("116", DEME_6);
			put("122", DEME_1);
			put("123", HIFUMI);
			put("124", MENASHI);
			put("125", MENASHI);
			put("126", MENASHI);
			put("133", DEME_1);
			put("134", MENASHI);
			put("135", MENASHI);
			put("136", MENASHI);
			put("144", DEME_1);
			put("145", MENASHI);
			put("146", MENASHI);
			put("155", DEME_1);
			put("156", MENASHI);
			put("166", DEME_1);
			put("222", ARASHI_2);
			put("223", DEME_3);
			put("224", DEME_4);
			put("225", DEME_5);
			put("226", DEME_6);
			put("233", DEME_2);
			put("234", MENASHI);
			put("235", MENASHI);
			put("236", MENASHI);
			put("244", DEME_2);
			put("245", MENASHI);
			put("246", MENASHI);
			put("255", DEME_2);
			put("256", MENASHI);
			put("266", DEME_2);
			put("333", ARASHI_3);
			put("334", DEME_4);
			put("335", DEME_5);
			put("336", DEME_6);
			put("344", DEME_3);
			put("345", MENASHI);
			put("346", MENASHI);
			put("355", DEME_3);
			put("356", MENASHI);
			put("366", DEME_3);
			put("444", ARASHI_4);
			put("445", DEME_5);
			put("446", DEME_6);
			put("455", DEME_4);
			put("456", SHIGORO);
			put("466", DEME_4);
			put("555", ARASHI_5);
			put("556", DEME_6);
			put("566", DEME_5);
			put("666", ARASHI_6);
		}
	};
	
	public static Yaku numsToYaku(int ... nums) {
		
		Arrays.sort(nums);
		String str = StringUtils.join(ArrayUtils.toObject(nums));
		return YAKU_MAP.get(str);
	}



}
